package ru.vsu.cs.piit.vokod.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Галчонок
 */
@Entity
@Table(name = "group_of_treatment")
@NamedQueries({@NamedQuery(name = "GroupOfTreatment.findAll", query = "SELECT g FROM GroupOfTreatment g"), @NamedQuery(name = "GroupOfTreatment.findByGroupOfTreatmentId", query = "SELECT g FROM GroupOfTreatment g WHERE g.groupOfTreatmentId = :groupOfTreatmentId"), @NamedQuery(name = "GroupOfTreatment.findByName", query = "SELECT g FROM GroupOfTreatment g WHERE g.name = :name"), @NamedQuery(name = "GroupOfTreatment.findByCode", query = "SELECT g FROM GroupOfTreatment g WHERE g.code = :code")})
public class GroupOfTreatment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "group_of_treatment_id")
    private Integer groupOfTreatmentId;
    @Column(name = "name")
    private String name;
    @Column(name = "code")
    private String code;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "groupOfTreatment")
    private List<Treatment> treatmentCollection;

    public GroupOfTreatment() {
    }

    public GroupOfTreatment(Integer groupOfTreatmentId) {
        this.groupOfTreatmentId = groupOfTreatmentId;
    }

    public Integer getGroupOfTreatmentId() {
        return groupOfTreatmentId;
    }

    public void setGroupOfTreatmentId(Integer groupOfTreatmentId) {
        this.groupOfTreatmentId = groupOfTreatmentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<Treatment> getTreatmentCollection() {
        return treatmentCollection;
    }

    public void setTreatmentCollection(List<Treatment> treatmentCollection) {
        this.treatmentCollection = treatmentCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (groupOfTreatmentId != null ? groupOfTreatmentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupOfTreatment)) {
            return false;
        }
        GroupOfTreatment other = (GroupOfTreatment) object;
        if ((this.groupOfTreatmentId == null && other.groupOfTreatmentId != null) || (this.groupOfTreatmentId != null && !this.groupOfTreatmentId.equals(other.groupOfTreatmentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getCode()+". "+getName();
    }

}
